import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render, formattingMin } from '/@/utils/common/renderUtils';

export const keyWorksColumns : BasicColumn[] = [
	{
		title: '关键词',
		align: "center",
		dataIndex: 'name',

	},
	{
		title: '排序',
		align: "center",
		dataIndex: 'sort',
	}
]


//列表数据
export const columns : BasicColumn[] = [
	/*   {
		title: '评论类型',
		align:"center",
		dataIndex: 'type'
	   }, */
	{
		title: '状态',
		align: "center",
		dataIndex: 'stats',
		customRender: ({ text }) => {
			if (text == 'Pass') return '审核通过'
			if (text == 'Invalid') return '审核失败'
			if (text == 'Audit') return '待审核'
		}
	},
	{
		title: '评论者',
		align: "center",
		dataIndex: 'userid_dictText'
	},
	{
		title: '排序',
		align: "center",
		dataIndex: 'marksort'
	},
	{
		title: '预设路线',
		align: "center",
		dataIndex: 'preLineName'
	},
	/* {
		title: '订单id',
		align: "center",
		dataIndex: 'bindtravelid'
	}, */
	{
		title: '评论时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}

	},
	{
		title: '回复时间',
		align: "center",
		dataIndex: 'replytime',
		customRender: ({ text }) => {
			if (text == 0) return ''
			return formattingMin(text)
		}
	},
	{
		title: '平均分',
		align: "center",
		dataIndex: 'avgscore'
	},
	{
		title: '游玩体验',
		align: "center",
		dataIndex: 'scoredetail',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.travelExpr + '分'

		}
	},
	{
		title: '行车助理',
		align: "center",
		dataIndex: 'scoredetail',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.driveAssist + '分'

		}
	},
	{
		title: '车辆体验',
		align: "center",
		dataIndex: 'scoredetail',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.carExpr + '分'

		}
	},
	{
		title: '评论内容',
		align: "center",
		dataIndex: 'evalcontent',
		customRender: ({ text }) => {
			let o = JSON.parse(text)
			return o.msg || ''

		}
	},

	{
		title: '图片',
		align: "center",
		dataIndex: 'images',
		customRender: ({ text }) => {
			let imgs = JSON.parse(text)
			return render.renderImage({ text: imgs.join(',') })
		}
	},
	{
		title: '回复内容',
		align: "center",
		dataIndex: 'replycontent',
		customRender: ({ text }) => {
			if (text == '') return ''
			let o = JSON.parse(text)
			return o.replyMsg || ''

		}
	},
	/* 	{
			title: '展示用，文本详情',
			align: "center",
			dataIndex: 'textdetail'
		},
		{
			title: '其他信息',
			align: "center",
			dataIndex: 'extinfor'
		}, */
];
//查询数据
export const searchFormSchema : FormSchema[] = [
];
//表单数据
export const formSchema : FormSchema[] = [
	{
		label: '审核状态',
		field: 'stats',
		component: 'JDictSelectTag',
		componentProps: {
			options: [
				{ label: '审核通过', value: 'Pass' },
				{ label: '待审核', value: 'Audit' },
				{ label: '未通过审核', value: 'Invalid' }
			]
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入评论类型!' },
			];
		},
	},
	{
		label: '排序',
		field: 'marksort',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入排序!' },
			];
		},
	},
	/* 	{
			label: '平均分',
			field: 'avgscore',
			component: 'InputNumber',
			dynamicRules: ({ model, schema }) => {
				return [
					{ required: true, message: '请输入平均分!' },
				];
			},
		},
		{
			label: '分值详情',
			field: 'scoredetail',
			component: 'InputTextArea',
			dynamicRules: ({ model, schema }) => {
				return [
					{ required: true, message: '请输入分值详情  json!' },
				];
			},
		}, */

	{
		label: '用户评价内容',
		field: 'msg',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入发布内容!' },
			];
		},
	},
	{
		label: '回复内容',
		field: 'replyMsg',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入回复内容!' },
			];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];

export const formSchemaKeyword : FormSchema[] = [
	{
		label: '关键词',
		field: 'name',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入关键词!' },
			];
		},
	},
	{
		label: '排序',
		field: 'sort',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输排序!' },
			];
		},
	},
]

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}